fix memory leak in strip_html().
authortsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 4 Aug 2013 23:01:55 +0000 (23:01 +0000)
committertsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 4 Aug 2013 23:01:55 +0000 (23:01 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4504 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/util.cc

index 1bc16c2e80dd97fa06399ea226385ffe6e252e18..d908e8c910ed401cfb40a6eb5b664175f32d10b3 100644 (file)
@@ -1563,7 +1563,8 @@ strip_html(const utf_string *in)
   char* outstring, *out;
   // If toUtf8() is used here, we double encode in the OSM test case.
   // this may be a bug here or elsewhere.
-  char* instr = xstrdup(in->utfstring.toLatin1().data());
+  char* incopy, *instr;
+  incopy = instr = xstrdup(in->utfstring.toLatin1().data());
   char tag[8];
   unsigned short int taglen = 0;
 
@@ -1637,6 +1638,9 @@ strip_html(const utf_string *in)
     instr++;
   }
   *out++ = 0;
+  if (incopy) {
+    xfree(incopy);
+  }
   return (outstring);
 }